package com.hzjq.fxlib.ui

import android.content.Context
import android.content.Intent
import androidx.recyclerview.widget.LinearLayoutManager
import com.hzjq.core.bean.ErrorCapEntity
import com.hzjq.fxlib.R
import com.hzjq.fxlib.adapter.RegisterAdapter
import com.hzjq.fxlib.event.LogEvent
import com.wxl.common.base.AbsActivity
import kotlinx.android.synthetic.main.activity_error_layout.*
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode

class ErrorCapActivity : AbsActivity() {

    companion object {
        fun start(context: Context, errors:ArrayList<ErrorCapEntity>){
            val intent = Intent(context,ErrorCapActivity::class.java)
            intent.putExtra("caps",errors)
            context.startActivity(intent)
        }
    }

    private var errors = arrayListOf<ErrorCapEntity>()
    private val mRegisterAdapter = RegisterAdapter(arrayListOf())

    override fun getCreateContentViewId(): Int {
        return R.layout.activity_error_layout
    }

    override fun getPageTitle(): String {
        return "错误雷管信息"
    }

    override fun onCreateViewChanged() {
        errors.clear()
        errors.addAll(intent.getSerializableExtra("caps") as ArrayList<ErrorCapEntity>)
        registerCapListView.layoutManager = LinearLayoutManager(this)
        registerCapListView.adapter = mRegisterAdapter
        mRegisterAdapter.setNewInstance(errors)
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    fun onLogEvent(e: LogEvent){

    }
}